package javabase.collection.list.thread;

import java.util.List;
import java.util.Vector;

class ListRun implements Runnable {
	
	private Vector<String> list = new Vector<String>();
	
	public ListRun() {
		
	}

	public List<String> getList() {
		return list;
	}

	public void setList(Vector<String> list) {
		this.list = list;
	}

	public void run() {
		for (int i = 0; i < 600; i++) {
			list.add(i + "");
			System.out.println(i);
		}
		
		/*Iterator<String> e = list.iterator();
		while (e.hasNext()) {
			System.out.print(e.next());
		}
		System.out.println("\n------无比华丽的分割线------");*/
	}
	
}

public class ArrayListNoSecurity {

	public static void main(String[] args) {
		
		// 抛出java.util.ConcurrentModificationException
		/*List<String> list = new ArrayList<String>();
		ListRun myRunable0 = new ListRun(list);
		ListRun myRunable1 = new ListRun(list);
		Thread myThread0 = new Thread(myRunable0);
		Thread myThread1 = new Thread(myRunable1);
		myThread0.start();
		myThread1.start();
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}
		Iterator<String> e = list.iterator();
		while (e.hasNext()) {
			System.out.print(e.next());
		}
		System.out.println("\n------无比华丽的分割线------"); //001123445
		 */
	}

}
